package com.jianyun.jyzs.presenter;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.jianyun.jyzs.dao.EngProjectDao;
import com.jianyun.jyzs.dao.EngineerDao;
import com.jianyun.jyzs.model.EngineerModel;
import com.jianyun.jyzs.model.imdoel.IEngineerModel;
import com.jianyun.jyzs.view.iview.IEngieerView;

import java.util.HashMap;

/**
 * @author 杨仕俊
 * @description 工程动态列表界面presenter
 * <p>
 * Created by yangshijun on 2018/5/30.
 */

public class EngieerPresenter extends MvpBasePresenter<IEngieerView> {
    /**
     * 获取工程动态列表
     *
     * @param dao
     * @param userid
     * @param enterpriseCode
     */
    public void getEngineer(EngineerDao dao, String userid, String enterpriseCode, String upOrDown) {
        if (!isViewAttached()) return;
        getView().showLoading();
        EngineerModel.getInstance().getEngineer(dao, userid, enterpriseCode, upOrDown, new IEngineerModel.OnGetEngineerListener() {
            @Override
            public void onSuccess() {
                getView().hintLoading();
                getView().getEngieerSuccess();
            }

            @Override
            public void onFailed(String msg) {
                getView().hintLoading();
                getView().onFailed(msg);
            }
        });
    }


    /**
     * 刷新获取工程动态列表
     *
     * @param dao
     * @param userid
     * @param enterpriseCode
     */
    public void getRefreshEngineer(EngineerDao dao, String userid, String enterpriseCode, String upOrDown) {
        if (!isViewAttached()) return;
        getView().showLoading();
        EngineerModel.getInstance().getRefreshEngineer(dao, userid, enterpriseCode, upOrDown, new IEngineerModel.OnRefeshListener() {
            @Override
            public void onSuccess() {
                getView().hintLoading();
                getView().refeshSuccess();
            }

            @Override
            public void onFailed(String msg) {
                getView().hintLoading();
                getView().onFailed(msg);
            }
        });
    }

}
